﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Authy.Net;
using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Table;

namespace MFAAuthyTest.Account
{
    public partial class Login : Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            //String dataConnectionString = "DefaultEndpointsProtocol=https;AccountName=aliciaauthy;AccountKey=UihKsy9AYk9R/UFMhpnxs9Ju459H+BVaUROJ5SJuGL7M2y8ILV8QwmeEK1gw+ga+AYwcF9nMjq5VPsztoGHT1Q==";
            //String tableName = "authy";
            //CloudStorageAccount account = CloudStorageAccount.Parse(dataConnectionString);
            //// create the table client
            //CloudTableClient tableClient = account.CreateCloudTableClient();
            //// create the table if it doesn't exist
            //CloudTable table = tableClient.GetTableReference(tableName);

            //TableQuery query = new TableQuery().Where(TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, User.Identity.Name));
            //String AuthyUserID = " ";

            //foreach (var entity in table.ExecuteQuery(query))
            //{
            //    AuthyUserID = entity.RowKey;
            //}

            //AuthyClient client = new AuthyClient("9d757c049978d32651d0e11e801b36f2", test: false);
            //VerifyTokenResult result = client.VerifyToken(AuthyUserID, TokenBox.Text, false);

            //if (!result.Status.Equals(AuthyStatus.Success))
            //{
            
                RegisterHyperLink.NavigateUrl = "Register";
                OpenAuthLogin.ReturnUrl = Request.QueryString["ReturnUrl"];

                var returnUrl = HttpUtility.UrlEncode(Request.QueryString["ReturnUrl"]);
                if (!String.IsNullOrEmpty(returnUrl))
                {
                    RegisterHyperLink.NavigateUrl += "?ReturnUrl=" + returnUrl;
                }
            //}
            
        }

 
    }
}